<template>
  <Portlet :title="title">
    <el-row>
      <el-col :span="24" v-if="!isEditing">
        <el-form label-position="left" label-width="130px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="公司编号:">
                <span>{{ data.code }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="状态:">
                <span>{{ data.state == 1 ? '启用' : '停用'}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公司名称:">
                <span>{{ data.name }}</span>
              </el-form-item>
            </el-col>

            <el-col :span="13">
              <el-form-item label="统一社会信用代码:">
                <span>{{ data.communityCode }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="法定代表人:">
                <span>{{ data.legalPerson }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公司联系人:">
                <span>{{ data.contactsName }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="联系人电话:">
                <span>{{ data.contactsPhone }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公司服务热线:">
                <span>{{data.serviceHotline}}</span>
              </el-form-item>
            </el-col>
            <el-col :span="13">
              <el-form-item label="公司住所:">
                <span>{{ data.province }} {{ data.city }} {{ data.district }} {{ data.detailAddress }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="LOGO:">
                <upload-image :formData="{}" :readonly="true"
                              :value="getImage(data.logo)"></upload-image>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="营业执照:">
                <upload-image :formData="{}" :readonly="true"
                              :value="getImage(data.businessLicense)"></upload-image>
              </el-form-item>
            </el-col>
            <el-col :span="24" v-if="data.carriageTestify">
              <el-form-item label="道路运输许可证:">
                <upload-image :formData="{}" :readonly="true"
                              :value="getImage(data.carriageTestify)"></upload-image>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div class="clearfix"></div>
      </el-col>
      <el-col :span="24" v-if="isEditing">
        <EditCompany :data="data" :isClickEditing="isEditing" @IsClickEditing="isEditing = false"></EditCompany>
      </el-col>
      <div style="position:absolute;top:-64px;right: 0px;" v-if="!isEditing">
        <el-button type="primary" @click="isEditing = true"> 编辑</el-button>
      </div>
    </el-row>
  </Portlet>
</template>
<script>
import {unixTimestampFilter} from '@/filters'
import EditCompany from '@/views/login/EditCompany'
// import {dotData, copy, confirm, alert} from '@/utils'
export default {
  components: {
    EditCompany
  },
  filters: {
    unixTimestampFilter
  },
  props: {
    data: {
      type: Object,
      default() {
        return {}
      }
    },
    title: {
      type: String,
      default: '公司信息'
    }
  },
  data() {
    return {
      isEditing: false
    }
  },
  methods: {
    getImage(val) {
      if (Array.isArray(val)) {
        return val
      }
      if (typeof val === 'string' && val) {
        return val.split(',')
      }
      return []
    }
  }
}
</script>
